var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, a) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var a in t)
              Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
          })(t, a);
      };
      return function (t, a) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        e(t, a),
          (t.prototype =
            null === a
              ? Object.create(a)
              : ((i.prototype = a.prototype), new i()));
      };
    })(),
  MonthCardView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_monthCard_back.on(Laya.Event.CLICK, t, t.onBackPre),
        WebSocketService.addListener({
          caller: t,
          code: 6600,
          method: t.onMonthCardData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6602,
          method: t.onMonthCardData1,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6601,
          method: t.onLingQuMonthCardData,
        }),
        t.btn_jiangcai_card.on(Laya.Event.CLICK, t, t.onJiangCaiCardAction),
        t.btn_yingcai_card.on(Laya.Event.CLICK, t, t.onJiangCaiCardAction),
        t.btn_jiangcai_lingqu.on(Laya.Event.CLICK, t, t.onLingQuJCClick),
        t.btn_yingcai_lingqu.on(Laya.Event.CLICK, t, t.onLingQuYCClick),
        WebSocketService.addListener({
          caller: t,
          code: 6603,
          method: t.onLoadCoinMoneyConsumeData,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openMonthCardView = function () {
        return (
          null == this.monthCardV && (this.monthCardV = new t()),
          WebSocketService.send({ c: 6600 }),
          this.monthCardV
        );
      }),
      (t.prototype.onBackPre = function () {
        this.removeSelf();
      }),
      (t.prototype.onLingQuJCClick = function () {
        WebSocketService.send({ c: 6601, d: { card: 98 } });
      }),
      (t.prototype.onLingQuYCClick = function () {
        WebSocketService.send({ c: 6601, d: { card: 38 } });
      }),
      (t.prototype.onJiangCaiCardAction = function (e) {
        if ("item_98" == e.target.name) {
          ("money_card_98");
          t = "确定使用33000金购买将才卡？";
          NormalDialog.showNormalDialog(
            t,
            this,
            this.reqLoadConsumCoinToJiangCaiCardFn
          );
        } else {
          ("money_card_38");
          var t = "确定使用13000金购买英才卡？";
          NormalDialog.showNormalDialog(
            t,
            this,
            this.reqLoadConsumCoinToYingCaiCardFn
          );
        }
      }),
      (t.prototype.reqLoadConsumCoinToJiangCaiCardFn = function () {
        WebSocketService.send({ c: 6603, d: { gold: 33e3 } });
      }),
      (t.prototype.reqLoadConsumCoinToYingCaiCardFn = function () {
        WebSocketService.send({ c: 6603, d: { gold: 13e3 } });
      }),
      (t.prototype.onLoadCoinMoneyConsumeData = function (e) {
        ToastView.toastView(e.msg),
          Laya.stage.event("GameMainView", "refreshMoney"),
          Laya.stage.event("HomePageView", "refreshMoney"),
          WebSocketService.send({ c: 6600 });
      }),
      (t.prototype.onMonthCardData = function (e) {
        if (0 == e.code) {
          var t,
            a,
            i = e.data.cards;
          if (1 == i.length) "38" == i[0].card ? (t = i[0]) : (a = i[0]);
          else if (2 == i.length)
            for (var n = 0; n < i.length; n++) {
              var o = i[n];
              "38" == o.card && (t = o), "98" == o.card && (a = o);
            }
          (this.label_card38_item.text = ""),
            (this.label_card38_item1.text = ""),
            (this.label_card38_item2.text = ""),
            (this.label_card98_item.text = ""),
            (this.label_card98_item1.text = ""),
            (this.label_card98_item2.text = ""),
            0 == t.stage
              ? ((this.btn_yingcai_lingqu.label = "未激活"),
                (this.btn_yingcai_lingqu.disabled = !0))
              : 1 == t.stage
              ? ((this.btn_yingcai_lingqu.label = "领取"),
                (this.btn_yingcai_lingqu.disabled = !1),
                (this.label_card38_item1.text = "(剩余时间："),
                (this.label_card38_item.text = this.timestampToTime(t.over)),
                (this.label_card38_item2.text = "天)"))
              : 2 == t.stage &&
                ((this.btn_yingcai_lingqu.label = "已领取"),
                (this.btn_yingcai_lingqu.disabled = !0),
                (this.label_card38_item1.text = "(剩余时间："),
                (this.label_card38_item.text = this.timestampToTime(t.over)),
                (this.label_card38_item2.text = "天)")),
            0 == a.stage
              ? ((this.btn_jiangcai_lingqu.label = "未激活"),
                (this.btn_jiangcai_lingqu.disabled = !0))
              : 1 == a.stage
              ? ((this.btn_jiangcai_lingqu.label = "领取"),
                (this.btn_jiangcai_lingqu.disabled = !1),
                (this.label_card98_item1.text = "(剩余时间："),
                (this.label_card98_item.text = this.timestampToTime(a.over)),
                (this.label_card98_item2.text = "天)"))
              : 2 == a.stage &&
                ((this.btn_jiangcai_lingqu.label = "已领取"),
                (this.btn_jiangcai_lingqu.disabled = !0),
                (this.label_card98_item1.text = "(剩余时间："),
                (this.label_card98_item.text = this.timestampToTime(a.over)),
                (this.label_card98_item2.text = "天)"));
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onMonthCardData1 = function (e) {
        0 == e.code || ToastView.toastView(e.msg);
      }),
      (t.prototype.onLingQuMonthCardData = function (e) {
        WebSocketService.send({ c: 6600 }),
          Laya.stage.event("GameMainView", "refreshMoney"),
          Laya.stage.event("HomePageView", "refreshMoney");
      }),
      (t.prototype.timestampToTime = function (e) {
        var t = new Date(),
          a = new Date(e).getTime() - t.getTime(),
          i = Math.floor(a / 1e3 / 60 / 60 / 24);
        Math.floor((a / 1e3 / 60 / 60) % 24),
          Math.floor((a / 1e3 / 60) % 60),
          Math.floor((a / 1e3) % 60);
        return i + "";
      }),
      t
    );
  })(ui.MoneyBankController.MonthCardViewUI);
